﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.IO;

namespace SQLDao
{
    public class SQL_Dao : IDisposable
    {
        public static readonly string conStr = string.Format("Data Source=.\\SQLEXPRESS;AttachDbFilename={0};Integrated Security=True;User Instance=True", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data\\Database1.mdf"));
        public static SqlConnection Connection = new SqlConnection();

        public SQL_Dao()
        {
            if (SQL_Dao.Connection.State != System.Data.ConnectionState.Open)
            {
                try
                {
                    SQL_Dao.Connection.ConnectionString = conStr;
                    
                    SQL_Dao.Connection.Open();
                }
                catch(Exception e)
                {

                }
            }
        }

        public void Dispose()
        {
            SQL_Dao.Connection.Close();
        }
    }
}
